package com.kgar.controller;

import com.kgar.dto.Result;
import com.kgar.dto.UserDTO;
import com.kgar.service.AsyncService;
import com.kgar.util.UserHolder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;

/**
 * @author Trimb
 */
@RestController
@EnableAsync
@Slf4j
@RequestMapping("async")
public class AsyncController {

    @Resource
    private AsyncService asyncService;

    @GetMapping("bestJob")
    public Result getBestJob() throws InterruptedException {
        UserDTO userDTO = UserHolder.getUser();
        asyncService.asyncGetBestJob(userDTO);
        return Result.ok();
    }

}
